unit Con_ItemPedVenda;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Formulario_Padrao_Consulta, StdCtrls, Buttons, ExtCtrls, Grids, DBGrids,
  Db, Dbtables;

type
  TFrmCon_ItemPedVenda = class(TFrmConsulta)
    Label1: TLabel;
    EdtPed_item: TEdit;
    DbgItem: TDBGrid;
    procedure BtnFecharClick(Sender: TObject);
    procedure EdtPed_itemKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FormActivate(Sender: TObject);
  private
    { Private declarations }
    procedure FazConsulta;
  public
    { Public declarations }
    Ped_Item : String;
    Ped_numero : String;
  end;

var
  FrmCon_ItemPedVenda: TFrmCon_ItemPedVenda;

implementation

Uses Dm, Biblio, clsPedidosVenda, clsItemPedVenda;

{$R *.DFM}

var ItemPedVenda : TItemPedVenda;
    tds          : Tdatasource;
    tq           : Tquery;

procedure TFrmCon_ItemPedVenda.BtnFecharClick(Sender: TObject);
begin
  inherited;
  Ped_item:=tq.fieldbyname('Ped_item').asstring;
  tds.free;
  tq.free;
end;

procedure TFrmCon_ItemPedVenda.EdtPed_itemKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  inherited;
  if key=12 then begin
    FazConsulta;
    EdtPed_item.setfocus;
  end;
end;

procedure TFrmCon_ItemPedVenda.FormActivate(Sender: TObject);
begin
  inherited;
  tds:=TDataSource.create(FrmCon_ItemPedVenda);
  tq:=Tquery.create(FrmCon_ItemPedVenda);
  tq.databasename:=dmint.db.databasename;
  tq.active:=False;
  tds.DataSet:=tq;
  fazconsulta;
  EdtPed_item.setfocus;
end;

procedure TFrmCon_ItemPedVenda.FazConsulta;
begin
  ItemPedVenda:=TItemPedVenda.Create;
  ItemPedVenda.Consultar(tq,Ped_numero);
  tq.open;
  ItemPedVenda.free;
  dbgItem.DataSource := tds;
  dbgItem.Refresh;
end;

end.
